// components/nav/scrollnav.js
// var common = require('../../mixins/common');

Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    nav:{
      type:Array,
      value:[]
    }
  },
  
  /**
   * 组件的初始数据
   */
  data: {
    pagewidth: 375,
  },
  ready(){
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          pagewidth: res.windowWidth
        })
      }
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // ...common,
    onnavscroll(e) {
      var offsetLeft = e.detail.scrollLeft;
      var scrollWidth = e.detail.scrollWidth - (this.data.pagewidth);
      var left = offsetLeft / scrollWidth * 100;
      left = left.toFixed(0)
      this.setData({
        scrollleft: left
      })
    },
    navigateTo(ev) {
      var dataset = ev.currentTarget.dataset
      var url = dataset.url;
      var app = getApp()
  
      if (dataset.auth && dataset.auth == 1) {
        app.xc_sys_config.authop.oppower("login").then(function (res) {
          app.xc_sys_config.router.navigateTo(url)
        })
  
      } else {
        app.xc_sys_config.router.navigateTo(url)
      }
  
    },
  
  }
})
